local skel = fk.CreateSkill{
  name = "lb__chengzhuo",
}

Fk:loadTranslationTable{
  ["lb__chengzhuo"] = "承灼",
  --[":lb__chengzhuo"] = "每回合限两次，体力值不大于你的角色成为其他角色牌的唯一目标后，你可令之改为【火攻】并转移给你，若造成伤害，你可以对伤害来源使用此牌。",
  --9.12
  --[":lb__chengzhuo"] = "每回合限一次，体力值不大于你的角色成为其他角色牌的唯一目标后，你可令之改为【火攻】并转移给你，若造成伤害，你可以对伤害来源使用此牌。",
  --9.20
  [":lb__chengzhuo"] = "每回合限一次，体力值不大于你的角色成为其他角色牌的唯一目标后，若你有手牌，你可令之改为【火攻】并转移给你，若造成伤害，你可以对伤害来源使用此牌。",

  ["#lb__chengzhuo"] = "承灼：你可以令 %arg 改为【火攻】并转移给你",
  ["#lb__chengzhuo_2"] = "承灼：你可以令 %arg 改为【火攻】",
  ["#lb__chengzhuo_use"] = "承灼：你可以对 %dest 使用 %arg ",

  ["$lb__chengzhuo1"] = "存护之志！ ",
  ["$lb__chengzhuo2"] = "坚不可摧。",
  ["$lb__chengzhuo3"] = "以强援弱！",
  ["$lb__chengzhuo4"] = "炎枪——冲锋！",
}

skel:addEffect(fk.TargetConfirming, {
  audio_index = {1, 2, 3},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and player:usedSkillTimes(skel.name) < 1 and not player:isKongcheng()
    and target.hp <= player.hp and data.from ~= player and data.from ~= target and data:isOnlyTarget(target)
    and data.card.name ~= "fire_attack" and not data.cancelled
  end,
  on_cost = function (self, event, target, player, data)
    local prompt = (target == player and "#lb__chengzhuo_2:::"..data.card:toLogString() or "#lb__chengzhuo:::"..data.card:toLogString() )
    return player.room:askToSkillInvoke(player, {skill_name = skel.name, prompt = prompt })
  end,
  on_use = function(self, event, target, player, data)
    data:changeCard("fire_attack", nil, nil, skel.name)
    if not data.from:isProhibited(player, data.card) and not player.dead then
      if target ~= player then
        data:cancelCurrentTarget()
        data:addTarget(player)
      end
      data.extra_data = data.extra_data or {}
      data.extra_data.lb__chengzhuo = player.id
    end
  end,
})

skel:addEffect(fk.Damaged, {
  is_delay_effect = true,
  audio_index = {1, 2, 3},
  can_trigger = function(self, event, target, player, data)
    if data.from and not data.from.dead and target == player and player:isAlive()
    and data.card and data.card:getEffectiveId() and player.room:getCardArea(data.card) == Card.Processing then
      local use = player.room.logic:getCurrentEvent():findParent(GameEvent.UseCard, true)
      return use and use.data.extra_data and use.data.extra_data.lb__chengzhuo and
      use.data.extra_data.lb__chengzhuo == target.id
    end
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local card = Fk:getCardById(data.card:getEffectiveId())
    local use = room:askToUseRealCard(player, {
      pattern = {card.id},
      skill_name = skel.name,
      cancelable = true,
      extra_data = {expand_pile = {card.id}, exclusive_targets = {data.from.id}},
      skip = true,
      prompt = "#lb__chengzhuo_use::"..data.from.id..":"..card:toLogString()
    })
    if use then
      use.extra_data = use.extra_data or {}
      use.extra_data.lb__chengzhuo_damage = player.id
      event:setCostData(self, {use = use})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    player.room:useCard(event:getCostData(self).use)
  end,
})
-- 彩蛋语音
skel:addEffect(fk.Damage, {
  can_refresh = function(self, event, target, player, data)
    if target == player and data.card then
      local use = player.room.logic:getCurrentEvent():findParent(GameEvent.UseCard, true)
      return use and use.data.extra_data and use.data.extra_data.lb__chengzhuo_damage and
      use.data.extra_data.lb__chengzhuo_damage == target.id
    end
  end,
  on_refresh = function(self, event, target, player, data)
    player:broadcastSkillInvoke(skel.name, 4)
  end,
})


return skel